//
//  UnusualCell.m
//  Zhiche-Carriage
//
//  Created by LeeBruce on 16/12/1.
//  Copyright © 2016年 LeeBruce. All rights reserved.
//

#import "UnusualCell.h"
#import <Masonry.h>

@implementation UnusualCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initSubviews];
    }
    
    return self;
}

-(void)initSubviews
{

__weak typeof(self) weakSelf = self;

//时间
self.timeLabel = [[UILabel alloc]init];
[self.contentView addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.left.mas_equalTo(10);
    make.top.mas_equalTo(0);
    make.size.mas_equalTo(CGSizeMake(200, 40 * kHeight));
    
}];
self.timeLabel.font = Font(14);
self.timeLabel.textColor = Color_RGB(51, 51, 51, 1);

//状态

self.statusLabel = [[UILabel alloc]init];
[self.contentView addSubview:self.statusLabel];
[self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.top.mas_equalTo(0);
    make.right.mas_equalTo(-10);
    make.size.mas_equalTo(CGSizeMake(100, 40 * kHeight));
    
}];
self.statusLabel.textAlignment = NSTextAlignmentRight;
self.statusLabel.textColor = YellowColor;
self.statusLabel.font = Font(10);

//起始地
UIImageView *startImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"start"]];
[self.contentView addSubview:startImg];
[startImg mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.left.mas_equalTo(15);
    make.top.mas_equalTo(weakSelf.timeLabel.mas_bottom).offset(10);
    make.size.mas_equalTo(CGSizeMake(15, 22));
    
}];


UILabel *rowL = [[UILabel alloc]init];
[self.contentView addSubview:rowL];
rowL.backgroundColor = LineGrayColor;
[rowL mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.left.mas_equalTo(startImg.mas_right).offset(10);
    make.top.equalTo(startImg);
    make.size.mas_equalTo(CGSizeMake(0.5, 50 ));
    
}];

self.startAddressLabel = [[UILabel alloc]init];
[self.contentView addSubview:self.startAddressLabel];
[self.startAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.left.mas_equalTo(rowL.mas_right).offset(10);
    make.top.equalTo(rowL);
    make.size.mas_equalTo(CGSizeMake(200, 22));
    
}];
self.startAddressLabel.font = Font(12);
self.startAddressLabel.textColor = AddressSCtitleColor;




//目的地
UIImageView *endImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"end"]];
[self.contentView addSubview:endImg];
[endImg mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.left.mas_equalTo(15);
    make.top.mas_equalTo(startImg.mas_bottom).offset(8);
    make.size.mas_equalTo(CGSizeMake(15, 22));
    
}];

self.endAddressLabel = [[UILabel alloc]init];
[self.contentView addSubview:self.endAddressLabel];
[self.endAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.left.mas_equalTo(rowL.mas_right).offset(10);
    make.top.equalTo(endImg);
    make.size.mas_equalTo(CGSizeMake(200, 22));
    
}];
self.endAddressLabel.font = Font(12);
self.endAddressLabel.textColor = AddressSCtitleColor;

//价格
self.moneyLabel = [[UILabel alloc]init];
[self.contentView addSubview:self.moneyLabel];
[self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.right.equalTo(weakSelf.statusLabel);
    make.top.equalTo(startImg);
    make.size.mas_equalTo(CGSizeMake(150, 50));
    
}];

self.moneyLabel.textAlignment = NSTextAlignmentRight;
self.moneyLabel.textColor = YellowColor;
self.moneyLabel.font = Font(17);


UILabel *lineL = [[UILabel alloc]init];
[self.contentView addSubview:lineL];
lineL.backgroundColor = LineGrayColor;
[lineL mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.left.mas_equalTo(10);
    make.top.equalTo(endImg.mas_bottom).offset(10);
    make.size.mas_equalTo(CGSizeMake(screenWidth - 10, 0.5 ));
    
}];


//查看详情
self.detailButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.contentView addSubview:self.detailButton];
[self.detailButton setTitle:@"查看详情" forState:UIControlStateNormal];
self.detailButton.backgroundColor = YellowColor;
[self.detailButton setTitleColor:WhiteColor forState:UIControlStateNormal];
[self.detailButton mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.right.mas_equalTo(-10);
    make.top.mas_equalTo(lineL.mas_bottom).offset(10* kHeight);
    make.size.mas_equalTo(CGSizeMake(100, 30 * kHeight));
    
}];
self.detailButton.layer.cornerRadius = 5;
self.detailButton.titleLabel.font = Font(14);



//在途信息
self.wayButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.contentView addSubview:self.wayButton];
[self.wayButton setTitle:@"在途信息" forState:UIControlStateNormal];
self.wayButton.backgroundColor = YellowColor;
[self.wayButton setTitleColor:WhiteColor forState:UIControlStateNormal];
[self.wayButton mas_makeConstraints:^(MASConstraintMaker *make) {
    
    make.right.mas_equalTo(weakSelf.detailButton.mas_left).offset(-10);
    make.top.equalTo(weakSelf.detailButton);
    make.size.equalTo(weakSelf.detailButton);
    
}];
self.wayButton.layer.cornerRadius = 5;
self.wayButton.titleLabel.font = Font(14);
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
